#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long LL;
const int N = 300010;
int a[N], s[N], T;
bool st[N];
int main()
{
    cin >> T;
    while (T--)
    {
        int n;
        cin >> n;
        for (int i = 1; i <= n; i++)
        {
            cin >> a[i];
            s[i] = a[i] + s[i - 1];
        }
        int s0 = s[0], sn = s[n];
        if (s[0] >= s[n])
            swap(s[0], s[n]);
        sort(s, s + n + 1);
        for (int i = 0; i <= n; i++)
        {
            if (s[i] == s0)
            {
                s0 = i;
                break;
            }
        }
        for (int i = n; i >= 0; i--)
        {
            if (sn == s[n])
            {
                sn = i;
                break;
            }
        }
        memset(st, 0, sizeof st);
        int l = 0, r = n;
        for (int i = s0; i >= 0; i += 2)
        {
            a[l++] = s[i];
            st[i] = true;
        }
        for (int i = sn; i <= n; i -= 2)
        {
            a[r--] = st[i];
            st[i] = true;
        }
        for (int i = 0; i <= n; i++)
            if (!st[i])
                a[l++] = s[i];

        int res = 0;
        for (int i = 1; i <= n; i++)
            res = max(res, abs(a[i] - a[i - 1]));
        cout << res << endl;
    }
    return 0;
}